// 小程序开发api接口统一配置
// 如果你的域名是： https://www.baidu.com/cn 那么这里只要填写 cn
let subDomain = ''; // 子域名，没有则为空

const API_BASE_URL = 'https://testshool.zzgoodqc.cn'; // 主域名

const request = (url, method = 'GET', data = {}) => {
	let _url = API_BASE_URL;
	if (subDomain) _url += `.${subDomain}`;
	_url += url;

	return new Promise((resolve, reject) => {
		uni.request({
			url: _url,
			method,
			data,
			header: {
				'content-type': 'application/json',
			},
			success: res => resolve(res.data),
			fail: err => {
				console.error('Request failed:', err);
				reject(err);
			},
			complete: () => {
				// 可以在这里执行请求完成后的统一操作
			}
		});
	});
};

module.exports = {
	request,
	// 示例接口调用
	webresinfo(data) {
		return request('/index.php/index/User/addWebuser', 'post', data);
	},
	weblogin(data){
		return request("/index.php/index/User/webLogin","post",data)
	},
	webgetlist(data){
		return request("/index.php/index/User/getWxStudentList","post",data)
	},
	webremove(data){
		return request("/index.php/index/User/delWxUser","post",data)
	},
	webaddlist(data){
		return request("/index.php/index/User/addWxUser","post",data)
	},
	webgetstudyinfo(data){
		return request("/index.php/index/User/getWxUserbyid","post",data)
	}
	// AddNewList(data) {
	// 	return request("/index.php/index/news/addNews", 'POST', data);
	// },
	// DelNewList(data){
	// 	return request("/index.php/index/news/delNews",'POST',data);
	// },
	// AddNum(data){
	// 	return request("/index.php/index/news/addNum",'POST',data);
	// },
	// Getinfo(data){
	// 	return request("/index.php/index/news/getNewsByid",'POST',data);
	// }
	// 确保所有其他接口方法也按需导出
};